package com.china.osourcechina;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.china.base.BaseActivity;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends BaseActivity {

    private Boolean b = false;

    @Override
    protected int loadWindowLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void initTitleBar() {

    }

    @Override
    protected void initViews() {
        init();
    }

    private void init() {
        Timer timer=new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                Message msg = new Message();
                msg.obj = true;
                handler.sendMessage(msg);
            }
        };
        timer.schedule(task,2000);
    }

    Handler handler = new Handler(){

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            b = (Boolean) msg.obj;
            if(b==true){
                Intent intent=new Intent(MainActivity.this,HomeActivity.class);
                startActivity(intent);
                finish();
            }
        }
    };

}
